package com.heima.schedule.feign;

import com.heima.clients.schedule.ITaskClient;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.schedule.dto.TaskDto;
import com.heima.schedule.service.TaskInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author xiaquanen
 * @version 1.0
 * @project heima-leadnews
 * @date 2024/7/26 09:55:46
 */
@RestController
@Slf4j
public class TaskClient implements ITaskClient {

    @Autowired
    private TaskInfoService taskInfoService;

    /**
     * 添加消息
     *
     * @param taskDto
     * @return
     */
    @PostMapping("/api/v1/schedule/addTask")
    public ResponseResult addTask(@RequestBody TaskDto taskDto){
        log.info("addTask:{}",taskDto);
       return taskInfoService.addTask(taskDto);
    }


    /**
     * 拉取消息
     *
     * @param taskType
     * @param priority
     * @return
     */
    @GetMapping("/api/v1/schedule/pullTask/{taskType}/{priority}")
    public ResponseResult pullTask(@PathVariable("taskType") Integer taskType, @PathVariable("priority") Integer priority){

        return  taskInfoService.pullTask(taskType,priority);
    }

}
